#include<stdio.h>
#include<string.h>
#include<stdlib.h>
FILE *fin = fopen("test.in","r");
FILE *fout = fopen("test.out","w");
char s1[200], s2[200];
int next[200];

int max(int a, int b)
{
	if(a > b) return a;
	return b;
}

void getnext()
{
	memset(next, 0, sizeof(next));
	int i = -1;
	unsigned j = 0;
	next[0] = -1;
	while(j < strlen(s2))
	{
		if(i==-1 || s2[i]==s2[j])
		{
			i++;  j++;
			next[j]=i;
		}
		else i = next[i];
	}
}

int KMP()
{
	int i=0, j=0, len1 = strlen(s1), len2 = strlen(s2);
	while((i < len1) && (j < len2))
	{
		if(j==-1 || s1[i]==s2[j]) {j++;i++;}
		else j = next[j];
	}
	if(j == len2) return i-len2;
	else return -1;
}

int index_KMP()
{
	int i = 0, j = 0, len1 = strlen(s1), len2 = strlen(s2), re = 0;
	while(i<len1 && j<len2)
	{
		if(j==-1 || s1[i]==s2[j]) {i++;j++;}
		else j = next[j];
		re = max(re,j);
	}
	return re;
}

int testKMP()
{
	fscanf(fin, "%s", s1);
	for(int i = 1; i <= 3; i++)
	{
		fscanf(fin, "%s",s2);
		getnext();
		fprintf(fout, "%d %d\n", KMP(), index_KMP());
	}
	return 0;
}
